package com.lsu.app.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lsu.app.bean.CourseScore;
import com.lsu.app.service.CourseScoreService;
import com.lsu.app.mapper.CourseScoreMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @description 针对表【course_score(课程评分表)】的数据库操作Service实现
 * @Date 2023-11-11 16:38:41
 * @author hjj
 */
@Service
public class CourseScoreServiceImpl extends ServiceImpl<CourseScoreMapper, CourseScore> implements CourseScoreService{
    private final CourseScoreMapper mapper;

    public CourseScoreServiceImpl(CourseScoreMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public Double getValScoreByCourseId(Integer courseId) {
        Integer in = mapper.getCountByCourseId(courseId);
        if(in==0){
            return 0.0;
        }
        return (double) (mapper.getScoreByCourseId(courseId)/in);
    }
}




